package com.wu.pojo.dto;

import com.wu.pojo.po.orgPo.DataBak;
import com.wu.pojo.po.orgPo.OrgBase;
import com.wu.pojo.po.userPo.User;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import javax.validation.constraints.NotNull;
import java.io.Serializable;

@Data
@ApiModel("用户注册DTO")
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
@SuppressWarnings("all")
public class RegisterDTO implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty("用户名(缺省orgid)")
    private String username;

    @ApiModelProperty("MD5加密后的密码")
    private String password;

    @ApiModelProperty("手机")
    private String mobile;

    @ApiModelProperty("传真")
    private String fax;

    @ApiModelProperty("邮箱")
    private String email;

    @ApiModelProperty("区域")
    private String belong;

    @ApiModelProperty("所属质监局")
    private String dict;

    @ApiModelProperty("统一信用代码")
    @NotNull(message = "统一信用代码不能为空")
    private String orgId;

    @ApiModelProperty("企业名")
    @NotNull(message = "企业名不能为空")
    private String orgName;

    @ApiModelProperty("法人姓名")
    @NotNull(message = "法人不能为空")
    private String legalName;

    @ApiModelProperty("法人身份证号")
    private String legalIdcard;

    @ApiModelProperty("法人证件名")
    private String legalIdName;

    @ApiModelProperty("法人证件路径")
    private String legalIdPath;

    @ApiModelProperty("机构区域")
    @NotNull(message = "地区不能为空")
    private String orgAddr;

    @ApiModelProperty("机构图片名称")
    private String orgFileName;

    @ApiModelProperty("机构图片路径")
    private String orgFilePath;

    @ApiModelProperty("联系人姓名")
    private String contactName;

    @ApiModelProperty("联系人身份证")
    private String contIdcard;

    @ApiModelProperty("联系人身份证名称")
    private String contIdcardName;

    @ApiModelProperty("联系人身份证路径")
    private String contPath;

    @ApiModelProperty("操作码 注册")
    private String opCode;

    @ApiModelProperty("验证码")
    private String checkCode;

    public User userInit() throws Exception {
        User user = new User();
        user.setUsername(username).
                setContactName(contactName).setContIdCard(contIdcard)
                .setMobile(mobile).setEmail(email).
                setFax(fax).setDict(dict).setStatus(1).setOrgId(orgId);
        return user;
    }

    public OrgBase orgInit() throws Exception {
        OrgBase orgBase = new OrgBase();
        orgBase.setOrgId(orgId).setOrgName(orgName).setLegalName(legalName).setLegalIdcard(legalIdcard)
                .setOrgAddr(orgAddr).setMobile(mobile).setContactName(contactName).setContIdcard(contIdcard)
                .setOrgFileName(orgFileName).setOrgFilePath(orgFilePath)
                .setLegalIdName(legalIdName).setLegalIdPath(legalIdPath)
                .setContIdcardName(contIdcardName).setContPath(contPath);
        return orgBase;
    }

}
